#!/usr/bin/gnuplot

reset


bm=0.1
lm=0.07
rm=0.98
gap=0.03
msize=0.8
ay1=0.0; ay2=3200; ay3=17000; ay4=25300;

unset key
set grid

set style data linespoints

set terminal png size 1000, 600

set multiplot 
set border 1+2+8
set xtics nomirror
set ytics nomirror

set xlabel "Instância"
#set ylabel "sftp(s)"

set lmargin at screen lm
set rmargin at screen rm
set bmargin at screen bm
set tmargin at screen bm + msize * (abs(ay2-ay1) / (abs(ay2-ay1) + abs(ay4-ay3) ) )
 
set mytics 4

set yrange [ay1:ay2]

plot "grafico.dat" using 2:xticlabels(1) title "BnB - primal", \
"" using 3:xticlabels(1) title "BnB - dual", \
"" using 4:xticlabels(1) title "PLI - primal", \
"" using 5:xticlabels(1) title "PLI - dual", \
"" using 6:xticlabels(1) title "Heuristica"

set x2tics nomirror
unset xtics
unset xlabel
#set key center right
set key reverse center Left outside
set grid x2tics

set border 2+4+8
set bmargin at screen bm + msize * (abs(ay2-ay1) / (abs(ay2-ay1) + abs(ay4-ay3) ) ) + gap
set tmargin at screen bm + msize + gap

set yrange [ay3:ay4]
set ytics 17000,500,25000

set label 'SFT' at screen 0.01, bm + 0.5 * (msize + gap) offset 0,-strlen("SFT")/4.0 rotate by 90


set arrow from screen lm - gap / 4.0, bm + msize * (abs(ay2-ay1) / (abs(ay2-ay1)+abs(ay4-ay3) ) ) - gap / 4.0  + gap to screen \
lm + gap / 4.0, bm + msize * (abs(ay2-ay1) / (abs(ay2-ay1) + abs(ay4-ay3) ) ) + gap / 4.0 + gap nohead

set arrow from screen rm - gap / 4.0, bm + msize * (abs(ay2-ay1) / (abs(ay2-ay1)+abs(ay4-ay3) ) ) - gap / 4.0 to screen \
rm + gap / 4.0, bm + msize * (abs(ay2-ay1) / (abs(ay2-ay1) + abs(ay4-ay3) ) ) + gap / 4.0 nohead

set arrow from screen rm - gap / 4.0, bm + msize * (abs(ay2-ay1) / (abs(ay2-ay1)+abs(ay4-ay3) ) ) - gap / 4.0  + gap to screen \
rm + gap / 4.0, bm + msize * (abs(ay2-ay1) / (abs(ay2-ay1) + abs(ay4-ay3) ) ) + gap / 4.0 + gap nohead

plot "grafico.dat" using 2:x2ticlabels(1) title "BnB - primal", \
"" using 3:x2ticlabels(1) title "BnB - dual", \
"" using 4:x2ticlabels(1) title "PLI - primal", \
"" using 5:x2ticlabels(1) title "PLI - dual", \
"" using 6:x2ticlabels(1) title "Heuristica"

unset multiplot
